package org.jeecg.modules.business.strategy.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.business.strategy.entity.MesSite;
import org.jeecg.modules.business.strategy.mapper.MesSiteMapper;
import org.jeecg.modules.business.strategy.service.IMesSiteService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: MES站点命名
 * @Author: jeecg-boot
 * @Date: 2023-11-24
 * @Version: V1.0
 */
@Service
public class MesSiteServiceImpl extends ServiceImpl<MesSiteMapper, MesSite> implements IMesSiteService {

    @Override
    public MesSite getMesSiteByInboundSite(String inboundSite) {
        MesSite mesSite = this.getOne(new LambdaQueryWrapper<MesSite>().eq(MesSite::getReturnMaterialSite, inboundSite));
        return mesSite;
    }

    @Override
    public MesSite getMesSiteByOutboundSite(String outboundSite) {
        MesSite mesSite = this.getOne(new LambdaQueryWrapper<MesSite>().eq(MesSite::getAskMaterialSite, outboundSite));
        return mesSite;
    }

    /**
     * 入库
     * 
     * @author hansen
     * @since 2024/1/6 13:57
     * @param inboundSite 
     * @return java.lang.String
     */
    @Override
    public String getMesInHouseByInboundSite(String inboundSite) {
        String house = "";
        List<MesSite> mesSites = this.list(new LambdaQueryWrapper<MesSite>().eq(MesSite::getAskMaterialSite, inboundSite));
        if (CollectionUtil.isNotEmpty(mesSites)) {
            MesSite mesSite = mesSites.get(0);
            house = mesSite.getMesInWarehouseId();
        }
        return house;
    }

    /**
     * 退料
     *
     * @author hansen
     * @since 2024/1/6 13:59
     * @param outboundSite
     * @return java.lang.String
     */
    @Override
    public String getMesBackHouseByOutboundSite(String outboundSite) {
        String house = "";
        List<MesSite> mesSites = this.list(new LambdaQueryWrapper<MesSite>().eq(MesSite::getReturnMaterialSite, outboundSite));
        if (CollectionUtil.isNotEmpty(mesSites)) {
            MesSite mesSite = mesSites.get(0);
            house = mesSite.getMesOutWarehouseId();
        }
        return house;
    }

    /**
     * 叫料
     *
     * @author hansen
     * @since 2024/1/6 13:58
     * @param outboundSite
     * @return java.lang.String
     */
    @Override
    public String getMesOutHouseByOutboundSite(String outboundSite) {
        String house = "";
        List<MesSite> mesSites = this.list(new LambdaQueryWrapper<MesSite>().eq(MesSite::getAskMaterialSite, outboundSite));
        if (CollectionUtil.isNotEmpty(mesSites)) {
            MesSite mesSite = mesSites.get(0);
            house = mesSite.getMesOutWarehouseId();
        }
        return house;
    }
}
